<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025/3/7
  Time: 10:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<body>
<form action="/bookManager/book/accountExist" method="post">
    <table align="center" border="1">
        <tr>
            <td>账号：</td>
            <td><input type="text" name="account" id="account"></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><input type="password" name="password"></td>
        </tr>
        <tr align="center">
            <td colspan="2"><input type="submit" value="提交"></td>
        </tr>
    </table>
</form>
</body>
</html>
<script>
    $(function () {
        $("#account").on("blur", function () {
            $.ajax({
                type: "GET",
                url: "/bookManager/book/accountExist?account=" + $("#account").val(),
                dataType: "json",
                success: function (data) {
                    if (data.exist == 1) {
                        console.log("该用户账号已存在")
                    } else if (data.exist == 0) {
                        console.log("该账号可以使用")
                    }
                }
            });
        })
    })
</script>